package com.dx.hsb.controller;

import com.alibaba.fastjson.JSON;
import com.dx.hsb.domain.RealTimeLocation;
import com.dx.hsb.service.RealTimeLocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/rtl")
public class RealTimeLocationController {

    @Autowired
    private RealTimeLocationService service;

    // 查询所有角色列表
    @GetMapping("/selectAll")
    public Object selectAll() {
        return service.selectAll();
    }

    // 通过id查询角色
    @GetMapping("/selectByPrimaryKey")
    public Object selectByPrimaryKey(Long id) {
        return service.selectByPrimaryKey(id);
    }

    // 增加一个角色
    @PostMapping("/insert")
    public Object insert(@RequestBody RealTimeLocation rtl) {
        return JSON.toJSONString("添加了" + service.insert(rtl) + "条记录!");
    }

    // 通过id删除一个角色
    @DeleteMapping("/deleteByPrimaryKey")
    public Object deleteByPrimaryKey(Long id) {
        return JSON.toJSONString("删除了" + service.deleteByPrimaryKey(id) + "条记录!");
    }

    // 更新一个角色
    @PutMapping("/updateByPrimaryKey")
    public Object updateByPrimaryKey(@RequestBody RealTimeLocation rtl) {
        return JSON.toJSONString("更新了" + service.updateByPrimaryKey(rtl) + "条记录!");
    }

    // 返回实体类的键值对
    @GetMapping("/getMapping")
    public Object getMapping() {
        return service.getMapping();
    }
}
